/**
 * @description 广场页 controller
 * @author chengpeng
 */

const {
    PAGE_SIZE
} = require('../config/constant')
const {
    SuccessModel
} = require('../model/ResModel')
const {
    getSquareCacheList
} = require('../cache/blog')


/**
 * @description 获取广场页微博
 * @author chengpeng
 * @param {number} pageIndex 页数
 */
async function getSquareBlogList(pageIndex = 0) {
    const result = await getSquareCacheList(pageIndex, PAGE_SIZE)
    const blogList = result.blogList

    return new SuccessModel({
        isEmpty: blogList.length === 0,
        blogList,
        pageSize: PAGE_SIZE,
        pageIndex,
        count: result.count
    })
}

module.exports = {
    getSquareBlogList
}